#!/usr/bin/env bash


whoami=`whoami`
if [ ! -e "/home/$whoami/.tmp/standby.pid" ];then
touch /home/$whoami/.tmp/standby.pid
fi


running()
{
if [ "ABC" == "ABC$1" ]
then
        return 1;
else
        CMD="ps -p $1|awk '{print \$1}'"
        r_pid=`ps -p $1|awk '{print \$1}'`
        if [ "x$r_pid" == "xPID" ]
        then
                return 1;
        else
                echo "PID $r_pid is running..."
                return 0;
        fi
fi
}

PID=`cat /home/$whoami/.tmp/standby.pid`

if running $PID
then
        echo "running..." >> /home/$whoami/.tmp/log/deamon
else
        echo "***R***" >> /home/$whoami/.tmp/log/deamon
        nohup sh /home/$whoami/.tmp/standby >/dev/null 2>&1 &
fi